package com.fp.vavr.example;

import org.junit.Test;

import java.util.Optional;
import static com.fp.vavr.example.Optionals.lift;

/**
 * Created by user on 17/9/11.
 */
public class LiftTest {

    @Test
    public void test(){
        NumberProvider numberProvider = ()->Optional.of(5);
        Math math = (a,b)->a/b;
        Optional<Double> result = divideFirstTwo(numberProvider,math);
        System.out.println(result);
    }

    public Optional<Double> divideFirstTwo(NumberProvider numberProvider, Math math) {
        return lift(math::divide).apply(numberProvider.getNumber(), numberProvider.getNumber());
    }
}
